How to call base class destructor from the derived class in PHP | PHP programs
We will call the destructor of the parent class from the destructor of the child class, here we need to use the parent keyword with :: (scope resolution operator).
<?php
class Base
{
function __destruct()
{
echo "Base:destructor called<br>";
}
}
class Derived extends Base
{
function __destruct()
{
echo "Derived:destructor called<br>";
parent::__destruct();
}
}
$dObj = new Derived();
?>


